#include <iostream>
using namespace std;
#define ok 0
#define MaxSize 100
#define OVERFLOW -1
#define ERROR 1
typedef int status;

#define MAXSIZE 100

//顺序栈
//栈非空，始终指向栈的上一个元素

typedef struct {
    int *base;
    int*top;
    int stackSize;

}SqStack;

//初始化栈
int  initStack(SqStack&s){

    s.base=new int[MAXSIZE];
    if(!s.base){
        exit(1);
    }

    s.top=s.base;//top和栈底相同
    s.stackSize=MAXSIZE;//stacksize置为栈的最大容量MAXSIZE
    return ok;
}

//插入元素
status Push(SqStack&s,int e){

    if(s.stackSize>=MaxSize){
        return ERROR;
    }

    *s.top==e;
    *s.top++;
    return ok;


}

//出战
status Pop(SqStack&s,int &e){

    if(s.top==s.base){
        return ERROR;//栈顶等于栈底 ，元素为空
    }

    e=*s.top;
    *s.top--;//栈顶减一
    return ok;    
}


int GetTop(SqStack s){
    if(s.top!=s.base){
        return *(s.top-1);

    }

}


//连战

typedef struct StackNode{
    int data;
    struct StackNode*next;
}StackNode,*LinkStack;


status InitSqStack(LinkStack&s){
    s=NULL;
    return ok;
}


//链栈插入
status Push(LinkStack&s,int e){

    StackNode *p=new StackNode;

    p->data=e;
    p->next=s;


}

//链栈出战
status Pop(LinkStack&s,int &e){

    LinkStack p;
    if(s==NULL) return ERROR;
    e=s->data;
    p=s;
    s=s->next;
    delete p;
    return ok;
}


//取栈顶元素
int GetTop(LinkStack s){

    if(s!=NULL){
        return s->data;
    }
}

//递归函数

long fact(long n){

    if(n==0)return 1;
    else{
        return n*fact(n-1);

    }


}





















